#!/bin/bash

if [ ! -d ../archives/resources ] ; then
   cmd="cd ../archives ; tar -xzf resources.tar.gz resources "
   echo "$cmd" ;  eval "$cmd"
fi

if [ ! -d ../archives/prebuilt-docs ] ; then
   cmd="cd ../prebuilt-docs ; tar -xzf prebuilt-docs.tar.gz prebuilt-docs "
   echo "$cmd" ;  eval "$cmd"
fi

# copy steganography data
if [ ! -f ../code/lib/xrn_steganography/inc/steg_data.h ] ; then
    cmd="cp ../archives/resources/steg_header/steg_data.h ../code/xrnlib/lib/xrn_steganography/inc/" 
    echo "$cmd" ;  eval "$cmd"
fi

# make directories

if [ ! -d $HOME/.local ] ; then
   cmd="mkdir $HOME/.local"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos ] ; then
   cmd="mkdir $HOME/.local/xoronos"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos/texmf ] ; then
   cmd="mkdir $HOME/.local/xoronos/texmf"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos/cache/ ] ; then
   cmd="mkdir $HOME/.local/xoronos/cache/"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos/texmf/tex ] ; then
   cmd="mkdir $HOME/.local/xoronos/texmf/tex"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos/resources ] ; then
   cmd="mkdir $HOME/.local/xoronos/resources"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.cache ] ; then
   cmd="mkdir $HOME/.cache"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.cache/xoronos ] ; then
   cmd="mkdir $HOME/.cache/xoronos"
   echo "$cmd" ; eval "$cmd"
fi

if [ ! -d $HOME/.local/xoronos/resources/sample_files ] ; then
   cmd="mkdir $HOME/.local/xoronos/resources/sample_files"
   echo "$cmd" ; eval "$cmd"
fi

# copy from resources
cmd="cp -r ../archives/resources/miscellaneus/tex/* $HOME/.local/xoronos/texmf/tex"
echo "$cmd" ; eval "$cmd"

cmd="cp ../archives/resources/code_examples/lorem_ipsum.txt $HOME/.local/xoronos/resources/plain_text.txt"
echo "$cmd" ; eval "$cmd"

cmd="cp -r ../archives/resources/sample_files/* $HOME/.local/xoronos/resources/sample_files/"
echo "$cmd" ; eval "$cmd"
